from re import S
from typing import List
from gensim.test.utils import common_texts
from gensim.corpora.dictionary import Dictionary
from gensim.models import LdaModel
from workflow.TextPayLoad import TextPayLoad

class GensimLDA(object):
    def __init__(self,**kward) -> None:
        """
        @description  :
        @param  :
        """
        super().__init__()
        self.lda = None
        self.HYPER_PARAM = None


    def train_LDA(self) -> None:
        pass
    
    def inferenc_LDA(self) -> List:
        pass

    def get_topics(self,num_topic=10,num_words=10) -> List:
        
        return LdaModel.print_topics(self.lda,num_topics=num_topic,num_words=num_words)


class ori_func:
    #获取corpus的词典
    #commen_texts:iterable of iterable of str [['human', 'interface', 'computer'],[],...]
    common_dictionary = Dictionary(common_texts)

    #构建bag-of-word向量
    #doc2bow return:list of `(token_id, token_count)` tuples
    common_corpus = [common_dictionary.doc2bow(text) for text in common_texts]


    lda = LdaModel(common_corpus, num_topics=3,id2word=common_dictionary)
    print(LdaModel.print_topics(lda,num_topics=3,num_words=1))
    